CC=g++
CFLAGS=-Wall -Werror -nostartfiles -nostdlib -nodefaultlibs -fno-rtti -fno-exceptions
LD=ld


BOOT=boot
DIRS=$(BOOT)

link-kernel: kernel
	@echo generating binary kernel
	@$(LD) -T linker.ld -o $^.bz $(BOOT)/loader.o $^.o

kernel: loader
	@echo compiling kernel
	@$(CC) -o $@.o -c $@.cc $(CFLAGS)

loader:
	@echo compiling kernel loader
	@make -C $(BOOT)

clean:
	@echo cleaning
	@rm -f *.o
	@rm -f *.bz
	@for dir in $(DIRS); do make -C $$dir clean; done
